;
$(function() {
    // page component init
    $("#adminTablesInfo").show();
    $("#foodTypeInfo").hide();
    $("#userInfo").hide();
    // head control
    $("#add_table").show();
    $("#add_foodtype").hide();
    $("#add_user").hide();
    // navbar[table] clicked
    $("a[data-name='tables']").click(function() {

      $("#adminTablesInfo").show();
      $("#foodTypeInfo").hide();
      $("#userInfo").hide();
      // head control
      $("#add_table").show();
      $("#add_foodtype").hide();
      $("#add_user").hide();
    });
    // navbar[foodType] clicked
    $("a[data-name='foodType']").click(function() {

      $("#adminTablesInfo").hide();
      $("#foodTypeInfo").show();
      $("#userInfo").hide();
      // head control
      $("#add_table").hide();
      $("#add_foodtype").show();
      $("#add_user").hide();
    });
    // navbar[users] clicked
    $("a[data-name='users']").click(function() {

      $("#adminTablesInfo").hide();
      $("#foodTypeInfo").hide();
      $("#userInfo").show();
      // head control
      $("#add_table").hide();
      $("#add_foodtype").hide();
      $("#add_user").show();
    });

    // table's link clicked -> table info
    $('#adminIndex > div > ul > li > a[data-name="tableInfo"]').click(
      function() {
        var url = "GetTableList.action";
        var tableid = $(this).attr("data-tableid");
        var send_data = expand({data : {
                                         tableId:tableid,
                                         fromPage:"adminIndex"
                                       }
                               },
            default_transition_option);
        $.mobile.changePage(url, send_data);
    });

    // foodType's link clicked -> foodType info
    $('#adminIndex > div > ul > li > a[data-name="foodTypeInfo"]').click(
        function() {
          var url = "GetFoodType.action";
          var foodtypeid = $(this).attr("data-foodtypeid");
          var send_data = expand({data : {
                                           foodtypeid:foodtypeid,
                                           fromPage:"adminIndex"
                                         }
                                 },
             default_transition_option);
          $.mobile.changePage(url, send_data);
      });
    
    // user's link clicked -> user info
    $('#adminIndex > div > ul > li > a[data-name="userInfo"]').click(
        function() {
          var url = "GetUserInfo.action";
          var userid = $(this).attr("data-userid");
          var send_data = expand({data : {
                                           userid:userid,
                                           fromPage:"adminIndex"
                                         }
                                 },
             default_transition_option);
          $.mobile.changePage(url, send_data);
        });

    // head[add_table] button clicked
    $('#adminIndex > div > #add_table').click(
        function() {
          var url = "addTable.action";
          var send_data = expand({data : {
                                            userid:userid,
                                            fromPage:"adminIndex"
                                         }
                                  },
             default_transition_option);
          $.mobile.changePage(url, send_data);
        });

    // head[add_foodtype] button clicked
    $('#adminIndex > div > #add_foodtype').click(
        function() {
          var url = "addTable.action";
          var send_data = expand({data : {
                                            userid:userid,
                                            fromPage:"adminIndex"
                                         }
                                  },
            default_transition_option);
          $.mobile.changePage(url, send_data);
        });

    // head[add_user] button clicked
    $('#adminIndex > div > #add_foodtype').click(
        function() {
          var url = "addTable.action";
          var send_data = expand({data : {
                                            userid:userid,
                                            fromPage:"adminIndex"
                                         }
                                  },
            default_transition_option);
          $.mobile.changePage(url, send_data);
        });
});